package edu.pku.sei.transformation.editor.controller.commands.node;

import edu.pku.sei.modeler.model.structure.MetaDiagram;
import edu.pku.sei.modeler.model.structure.MetaNode;
/**
 * @deprecated
 * @author von
 */
public class AdsorbedNodeDeleteCommand extends NestedCommand{
	private MetaDiagram diagram;
	private MetaNode node;

	public AdsorbedNodeDeleteCommand(MetaNode node, MetaDiagram diagram) {
		this.node = node;
		this.diagram = diagram;
	}

	@Override
	public boolean canExecute() {
		if (node != null && diagram != null) {
			return super.canExecute();
		} else {
			return false;
		}
	}

	@Override
	public void execute() {
		diagram.getNodes().remove(node);

		if (modelCmd != null) {
			modelCmd.execute();
		}
	}

	@Override
	public void undo() {
		diagram.getNodes().add(node);

		if (modelCmd != null) {
			modelCmd.undo();
		}
	}
}
